import flash.display.Shape;
import SquareModel;
import flash.events.Event;

class SquareView extends AVerletView
{
  //private override var model:SquareModel;
  public function new(squareModel:SquareModel)
  {
    super(squareModel);
  }
  override private function changeHandler(event:Event)
  {
      super.changeHandler(event);
  }

  override private function draw()
  {
    var shape:Shape = new Shape();
    shape.graphics.lineStyle(1);
    shape.graphics.beginFill(model.color);
    shape.graphics.drawRect(0, 0, model.width,model.height);
    shape.graphics.endFill();

    addChild(shape);
  }
  public function hit()
  {
    removeChildAt(0);
    var shape:Shape = new Shape();
    shape.graphics.lineStyle(1,0xFF0000);
    shape.graphics.beginFill(0xFF1111);
    shape.graphics.drawRect(0, 0, model.width,model.height);
    shape.graphics.endFill();

    addChild(shape);
  }
  public function unHit()
  {
    removeChildAt(0);
    var shape:Shape = new Shape();
    shape.graphics.lineStyle(1);
    shape.graphics.beginFill(model.color);
    shape.graphics.drawRect(0, 0, model.width,model.height);
    shape.graphics.endFill();

    addChild(shape);
  }
}